function InitialClick() {
    document.getElementById("InitialButton").style.display = "none";
    document.getElementById("InitialButton1").style.display = "block";
    document.getElementById("InitialButton2").style.display = "block";
    document.getElementById("InitialButton3").style.display = "block";
    document.getElementById("InitialButton4").style.display = "block";
}
function ShowInitialClick() {
    document.getElementById("InitialButton").style.display = "block";
    document.getElementById("InitialButton1").style.display = "none";
    document.getElementById("InitialButton2").style.display = "none";
    document.getElementById("InitialButton3").style.display = "none";
    document.getElementById("InitialButton4").style.display = "none";
}
function ImgAudioClick() {
    document.getElementById("audioBody").play();
}
function ResetClick() {
    history.go(0);
}
function close_win() {
    document.querySelectorAll("audio").forEach((audio) => audio.pause());
    document.getElementById("audioBodyRight").pause();
    currentTimestamp = Date.now();
    operationName = "end";
    additionalInfo = "out";
    CommonNetWork();
    api.openWin({
        name: "ExpressionMatchingSelect",
        url: "./ExpressionMatchingSelect.html",
        pageParam: {
            uid: userid,
            token: token,
        },
        reload: true,
    });
}

function close_win1() {
    api.openWin({
        name: "SubsetMenu-Advanced",
        url: "../../SubsetMenu-Advanced.html",
        pageParam: {
            uid: userid,
            token: token,
        },
        reload: true,
    });
}
//答对和答错
function hideRightPopup() {
    document.getElementById("backdrop_bgright").style.display = "none";
}
function hideMistake() {
    document.getElementById("backdropMistake").style.display = "none";
}
var i = 0;
var last = null;
var number = 0;
function clickDisappear(obj) {
    obj.classList.add("highlighted");

    if (i == 0 && last == null) {
        last = obj;
        i = 1;
    } else {
        if (obj != last) {
            if (obj.dataset.name == last.dataset.name) {
                number = number + 1;
                obj.style.display = "none";
                last.style.display = "none";
                document.getElementById("audioBodyRight0").play();
                currentTimestamp = Date.now();
                operationName = "ing";
                additionalInfo = "correct";
                CommonNetWork();
            } else {
                document.getElementById("audioBodyMistake").play();
                // 选择不匹配，则显示错误提示
                document.getElementById("backdropMistake").style.display = "block";
                setTimeout(() => {
                    document.getElementById("backdropMistake").style.display = "none";
                }, 2000);
                currentTimestamp = Date.now();
                operationName = "ing";
                additionalInfo = "error";
                CommonNetWork();
            }
            if (number == 2) {
                //    这里执行弹框操作
                document.getElementById("audioBodyRight").style.display = "none";
                document.getElementById("audioBodyRight").play();
                document.getElementById("backdrop_bgright").style.display = "block";
                setTimeout(() => {
                    document.getElementById("backdrop_bgright").style.display = "none";
                }, 5000);
            }
            i = 0;
            last = null;
        }
    }
}
// 3到5关
function clickDisappearOther(obj) {
    obj.classList.add("highlighted");
    obj.onclick = null;
    if (i == 0 && last == null) {
        last = obj;
        i = 1;
    } else {
        if (obj != last) {
            if (obj.dataset.name == last.dataset.name) {
                number = number + 1;
                obj.style.display = "none";
                last.style.display = "none";
                document.getElementById("audioBodyRight0").play();
                currentTimestamp = Date.now();
                operationName = "ing";
                additionalInfo = "right";
                CommonNetWork();
            } else {
                document.getElementById("audioBodyMistake").play();
                // 选择不匹配，则显示错误提示
                document.getElementById("backdropMistake").style.display = "block";
                setTimeout(() => {
                    document.getElementById("backdropMistake").style.display = "none";
                }, 2000);
                currentTimestamp = Date.now();
                operationName = "ing";
                additionalInfo = "error";
                CommonNetWork();
            }
            if (number == 3) {
                //    这里执行弹框操作
                document.getElementById("audioBodyRight").style.display = "none";
                document.getElementById("audioBodyRight").play();
                document.getElementById("backdrop_bgright").style.display = "block";
                setTimeout(() => {
                    document.getElementById("backdrop_bgright").style.display = "none";
                }, 5000);
            }
            i = 0;
            last = null;
        }
    }
}
function ClickSelect4(obj) {
    obj.classList.add("highlighted");
    obj.onclick = null;
    if (obj.dataset.name == "right") {
        document.getElementById("audioBodyRight").style.display = "none";
        document.getElementById("audioBodyRight").play();
        document.getElementById("backdrop_bgright").style.display = "block";
        setTimeout(() => {
            document.getElementById("backdrop_bgright").style.display = "none";
        }, 5000);
        document.getElementById("ImageError1").onclick = null;
        document.getElementById("ImageError2").onclick = null;
        document.getElementById("ImageError3").onclick = null;
        currentTimestamp = Date.now();
        operationName = "ing";
        additionalInfo = "correct";
        CommonNetWork();
    } else if (obj.dataset.name == "error1") {
        document.getElementById("audioBodyMistake").style.display = "none";
        document.getElementById("audioBodyMistake").play();
        document.getElementById("backdropMistake").style.display = "block";
        setTimeout(() => {
            document.getElementById("backdropMistake").style.display = "none";
        }, 2000);
        document.getElementById("ImageRight").onclick = null;
        document.getElementById("ImageError2").onclick = null;
        document.getElementById("ImageError3").onclick = null;
        currentTimestamp = Date.now();
        operationName = "ing";
        additionalInfo = "error";
        CommonNetWork();
    } else if (obj.dataset.name == "error2") {
        document.getElementById("audioBodyMistake").style.display = "none";
        document.getElementById("audioBodyMistake").play();
        document.getElementById("backdropMistake").style.display = "block";
        setTimeout(() => {
            document.getElementById("backdropMistake").style.display = "none";
        }, 2000);
        document.getElementById("ImageRight").onclick = null;
        document.getElementById("ImageError1").onclick = null;
        document.getElementById("ImageError3").onclick = null;
        currentTimestamp = Date.now();
        operationName = "ing";
        additionalInfo = "error";
        CommonNetWork();
    } else if (obj.dataset.name == "error3") {
        document.getElementById("audioBodyMistake").style.display = "none";
        document.getElementById("audioBodyMistake").play();
        document.getElementById("backdropMistake").style.display = "block";
        setTimeout(() => {
            document.getElementById("backdropMistake").style.display = "none";
        }, 2000);
        document.getElementById("ImageRight").onclick = null;
        document.getElementById("ImageError1").onclick = null;
        document.getElementById("ImageError2").onclick = null;
        currentTimestamp = Date.now();
        operationName = "ing";
        additionalInfo = "error";
        CommonNetWork();
    } else if (obj.dataset.name == "other") {
        obj.onclick = null;
        obj.classList.remove("highlighted");
    }
}
function TipsClick() {
    document.getElementById("floatingImage1").style.display = "block";
    document.getElementById("floatingImage3").style.display = "block";
    setTimeout(() => {
        document.getElementById("floatingImage1").style.display = "none";
        document.getElementById("floatingImage3").style.display = "none";
        document.getElementById("floatingImage2").style.display = "block";
        document.getElementById("floatingImage4").style.display = "block";
    }, 2000);
    setTimeout(() => {
        document.getElementById("floatingImage2").style.display = "none";
        document.getElementById("floatingImage4").style.display = "none";
    }, 4000);
}
function TipsClickOther() {
    document.getElementById("floatingImage1").style.display = "block";
    document.getElementById("floatingImage3").style.display = "block";
    setTimeout(() => {
        document.getElementById("floatingImage1").style.display = "none";
        document.getElementById("floatingImage3").style.display = "none";
        document.getElementById("floatingImage2").style.display = "block";
        document.getElementById("floatingImage4").style.display = "block";
    }, 2000);
    setTimeout(() => {
        document.getElementById("floatingImage2").style.display = "none";
        document.getElementById("floatingImage4").style.display = "none";
        document.getElementById("floatingImage5").style.display = "block";
        document.getElementById("floatingImage6").style.display = "block";
    }, 4000);
    setTimeout(() => {
        document.getElementById("floatingImage5").style.display = "none";
        document.getElementById("floatingImage6").style.display = "none";
    }, 6000);
}
//表情指认
function TipsClickIdentify() {
    document.getElementById("floatingImage1").style.display = "block";
    setTimeout(() => {
        document.getElementById("floatingImage1").style.display = "none";
    }, 2000);
}
function ClickSelectIdentify(obj) {
    obj.classList.add("highlighted");
    obj.onclick = null;
    if (obj.dataset.name == "right") {
        document.getElementById("audioBodyRight").play();
        document.getElementById("backdrop_bgright").style.display = "block";
        setTimeout(() => {
            document.getElementById("backdrop_bgright").style.display = "none";
        }, 5000);
        document.getElementById("ImageError1").onclick = null;
        document.getElementById("ImageError2").onclick = null;
        currentTimestamp = Date.now();
        operationName = "ing";
        additionalInfo = "";
        CommonNetWork();
    }
    if (obj.dataset.name == "error1") {
        document.getElementById("backdropMistake").style.display = "block";
        document.getElementById("audioBodyMistake").play();
        setTimeout(() => {
            document.getElementById("backdropMistake").style.display = "none";
        }, 2000);
        document.getElementById("ImageRight").onclick = null;
        document.getElementById("ImageError2").onclick = null;
        currentTimestamp = Date.now();
        operationName = "ing";
        additionalInfo = "";
        CommonNetWork();
    } else if (obj.dataset.name == "error2") {
        document.getElementById("backdropMistake").style.display = "block";
        document.getElementById("audioBodyMistake").play();
        setTimeout(() => {
            document.getElementById("backdropMistake").style.display = "none";
        }, 2000);
        document.getElementById("ImageRight").onclick = null;
        document.getElementById("ImageError1").onclick = null;
        currentTimestamp = Date.now();
        operationName = "ing";
        additionalInfo = "";
        CommonNetWork();
    }
}
